<?php

namespace Proyecto\MainBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\ORM\EntityRepository;

class UsuarioType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('usuario')
            ->add('password')
            ->add('nomyap')
            ->add('email')
            ->add('telefono')
        ;
        $builder->add('perfil','entity', array('required' => true, 
                                               'class' =>'ProyectoMainBundle:Perfil',
                                               'query_builder' => function(EntityRepository $er)
                                                {
                                                  return $er->createQueryBuilder('p')
                                                  ->where("p.perfil != 'admin' ");
                                                },
                                                'empty_value'=>'Seleccione un perfil',
                                               ));  
	$builder->add('cvPublico','checkbox', array('required' => false));
	$builder->add('activo','checkbox', array('required' => false));
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Proyecto\MainBundle\Entity\Usuario',
        ));
    }
    
    public function getName()
    {
        return 'proyecto_mainbundle_usuariotype';
    }
}
